<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 求1-100之间所有数的平均值 需要一个sum和变量 还需要一个平均值
        var sum = 0;
        var average = 0;
        for (var i = 0; i <= 100; i++) {
            sum = sum + i
        }
        average = sum / 100;
        console.log(average)
        // 求1-100之间所有偶数奇数之和 我们需要一个偶数的变量even还需要一个奇数odd
        var odd = 0;
        var even = 0;
        for (var i = 0; i <= 100; i++) {
            if (i % 2 == 0) {
                even = even + i
            } else {
                odd = odd + i
            }
        }
        console.log(`1-100之间所有的偶数和是:${even}`);
        console.log(`1-100之间所有的奇数和是:${odd}`);
        // 求1-100之间所有能被3整除的数字的和
        var expected = 0;
        for (var i = 1; i <= 100; i++) {
            if (i % 3 == 0) {
                expected += i
            }
        }
        console.log(`1-100之间能够被3整除的数字的和是:${expected}`);
    </script>
</body>

</html>